[#391] Batch RPC calls with multicall on home page#392
Conversation
Add getBatchTokenData() to lib/price.ts — fetches price + TVL for all tokens in a single multicall (3 calls per token → 1 RPC request). Home page now uses StoryGrid → BatchTokenDataProvider context. StoryCardTVL consumes batch data when available, falls back to individual fetch on detail pages. Reduces ~32 simultaneous RPC calls to 1 multicall request. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
LGTM. Clean multicall batching — 3 calls per token grouped into a single RPC request. Context provider + useQuery with fallback for individual pages is well-structured. StoryCardTVL gracefully falls back when batch context isn't available. CI green.
Minor note (not blocking): getBatchTokenData() in lib/price.ts uses server-side publicClient, but runs in browser via useQuery. Pre-existing pattern (getTokenTVL/getTokenPrice have the same issue), so out of scope for this PR.
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
The batching idea is good, but the new client-side path is wired to the wrong RPC client.
Findings
- [high] BatchTokenDataProvider is a browser component that calls getBatchTokenData(), but getBatchTokenData() uses the server publicClient from lib/price.ts. That recreates the browser-side transport problem from #389, just through one multicall instead of many individual calls.
- File: src/components/BatchTokenDataProvider.tsx:30
- File: lib/price.ts:2
- File: lib/price.ts:310
- Suggestion: route this batched home-page fetch through the browser-safe client, or move the batched read to a server-rendered path instead of a client useQuery.
Decision
Requesting changes because the new home-page batching flow currently runs in the browser while still depending on the server RPC client, which can reintroduce the exact browser transport and rate-limit issue this codebase just fixed.
getBatchTokenData() now accepts optional client parameter. BatchTokenDataProvider passes browserClient (CORS-safe) instead of server publicClient. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
The browser-side multicall path is now wired correctly. The batch helper accepts an injected client, and the client-side provider passes browserClient for the home-page multicall.
Findings
- None.
Decision
Approved. The earlier browser-transport regression is resolved, the home page batching approach matches issue #391, and the latest lint-and-typecheck run is green.
Summary
getBatchTokenData()tolib/price.ts— batchespriceForNextMint,totalSupply, andtokenBondfor all tokens into a singlemulticallRPC requestBatchTokenDataProvidercontext component distributes batch results to child cardsStoryGridwraps the home page card grid with the batch providerStoryCardTVLconsumes batch context when available, falls back to individualgetTokenTVL()on detail pagesgetTokenPrice()/getTokenTVL()kept intact for single-story pagesResult: ~32 simultaneous RPC calls → 1 multicall request
Fixes #391
Test plan
npm run typecheck— passesnpm run lint— passes🤖 Generated with Claude Code